<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>MiXiM: AlohaMacLayer Class Reference</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>


</head>
<body>
<div id="top"><!-- do not remove this div! -->


<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">MiXiM
   &#160;<span id="projectnumber">2.3</span>
   </div>
   
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.7.5.1 -->
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li class="current"><a href="annotated.html"><span>Classes</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
      <li><a href="dirs.html"><span>Directories</span></a></li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="annotated.html"><span>Class&#160;List</span></a></li>
      <li><a href="classes.html"><span>Class&#160;Index</span></a></li>
      <li><a href="inherits.html"><span>Class&#160;Hierarchy</span></a></li>
      <li><a href="functions.html"><span>Class&#160;Members</span></a></li>
    </ul>
  </div>
</div>
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
  initNavTree('a00008.html','');
</script>
<div id="doc-content">
<div class="header">
  <div class="summary">
<a href="#pub-methods">Public Member Functions</a> &#124;
<a href="#pub-attribs">Public Attributes</a> &#124;
<a href="#pro-methods">Protected Member Functions</a> &#124;
<a href="#pri-methods">Private Member Functions</a>  </div>
  <div class="headertitle">
<div class="title">AlohaMacLayer Class Reference<div class="ingroups"><a class="el" href="a00524.html">IEEE 802.15.4A - Classes that implement the IEEE 802.15.4A UWB PHY.</a> &#124; <a class="el" href="a00509.html">macLayer - MAC layer modules</a></div></div>  </div>
</div>
<div class="contents">
<!-- doxytag: class="AlohaMacLayer" --><!-- doxytag: inherits="UWBIRMac" -->
<p>this class implements a basic Aloha MAC protocol for an UWB-IR IEEE 802.15.4A transceiver to allow testing the PHY layer.  
 <a href="a00008.html#details">More...</a></p>

<p><code>#include &lt;<a class="el" href="a00422_source.html">AlohaMacLayer.h</a>&gt;</code></p>
<div class="dynheader">
Inheritance diagram for AlohaMacLayer:</div>
<div class="dyncontent">
<div class="center"><img src="a00545.png" border="0" usemap="#AlohaMacLayer_inherit__map" alt="Inheritance graph"/></div>
<center><span class="legend">[<a target="top" href="graph_legend.html">legend</a>]</span></center></div>
<div class="dynheader">
Collaboration diagram for AlohaMacLayer:</div>
<div class="dyncontent">
<div class="center"><img src="a00546.png" border="0" usemap="#AlohaMacLayer_coll__map" alt="Collaboration graph"/></div>
<center><span class="legend">[<a target="top" href="graph_legend.html">legend</a>]</span></center></div>

<p><a href="a00547.html">List of all members.</a></p>
<table class="memberdecls">
<tr><td colspan="2"><h2><a name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">virtual void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00008.html#abab6939a0c82122391528d386df97c2c">initialize</a> (int stage)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Initialization of the module and some variables.  <a href="#abab6939a0c82122391528d386df97c2c"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a4c822fb23aeaf77651ce1278a9d12d4b"></a><!-- doxytag: member="AlohaMacLayer::finish" ref="a4c822fb23aeaf77651ce1278a9d12d4b" args="()" -->
virtual void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00008.html#a4c822fb23aeaf77651ce1278a9d12d4b">finish</a> ()</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Called when the simulation has finished. <br/></td></tr>
<tr><td colspan="2"><h2><a name="pub-attribs"></a>
Public Attributes</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="abcd74293a66cf3f4914abf131bba65b2"></a><!-- doxytag: member="AlohaMacLayer::minBE" ref="abcd74293a66cf3f4914abf131bba65b2" args="" -->
int&#160;</td><td class="memItemRight" valign="bottom"><b>minBE</b></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a1490b7aa9b05b1d0aed3ca802dccea22"></a><!-- doxytag: member="AlohaMacLayer::maxBE" ref="a1490b7aa9b05b1d0aed3ca802dccea22" args="" -->
int&#160;</td><td class="memItemRight" valign="bottom"><b>maxBE</b></td></tr>
<tr><td colspan="2"><h2><a name="pro-methods"></a>
Protected Member Functions</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">virtual macpkt_ptr_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00008.html#a52988f430b2def656fdb4b1f6dc15395">encapsMsg</a> (cPacket *msg)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Encapsulate the NetwPkt into an MacPkt.  <a href="#a52988f430b2def656fdb4b1f6dc15395"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">virtual void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00008.html#a585dd6a0b5c3c6a33e1f760ccd8ac29e">handleLowerMsg</a> (cMessage *msg)</td></tr>
<tr><td colspan="2"><h2><a name="pri-methods"></a>
Private Member Functions</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a6c77857ba89b8cb3af1e1182c6873b2b"></a><!-- doxytag: member="AlohaMacLayer::AlohaMacLayer" ref="a6c77857ba89b8cb3af1e1182c6873b2b" args="(const AlohaMacLayer &amp;)" -->
&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00008.html#a6c77857ba89b8cb3af1e1182c6873b2b">AlohaMacLayer</a> (const <a class="el" href="a00008.html">AlohaMacLayer</a> &amp;)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Copy constructor is not allowed. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ac00dc76f2fb840fe1e4bca8c7340bd2e"></a><!-- doxytag: member="AlohaMacLayer::operator=" ref="ac00dc76f2fb840fe1e4bca8c7340bd2e" args="(const AlohaMacLayer &amp;)" -->
<a class="el" href="a00008.html">AlohaMacLayer</a> &amp;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00008.html#ac00dc76f2fb840fe1e4bca8c7340bd2e">operator=</a> (const <a class="el" href="a00008.html">AlohaMacLayer</a> &amp;)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Assignment operator is not allowed. <br/></td></tr>
</table>
<hr/><a name="details" id="details"></a><h2>Detailed Description</h2>
<div class="textblock"><p>this class implements a basic Aloha MAC protocol for an UWB-IR IEEE 802.15.4A transceiver to allow testing the PHY layer. </p>
<p>This is not a complete implementation of the IEEE 802.15.4A non beacon enabled mode ! </p>
</div><hr/><h2>Member Function Documentation</h2>
<a class="anchor" id="a52988f430b2def656fdb4b1f6dc15395"></a><!-- doxytag: member="AlohaMacLayer::encapsMsg" ref="a52988f430b2def656fdb4b1f6dc15395" args="(cPacket *msg)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">AlohaMacLayer::macpkt_ptr_t AlohaMacLayer::encapsMsg </td>
          <td>(</td>
          <td class="paramtype">cPacket *&#160;</td>
          <td class="paramname"><em>netwPkt</em></td><td>)</td>
          <td><code> [protected, virtual]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Encapsulate the NetwPkt into an MacPkt. </p>
<p>Encapsulates the received NetwPkt into a MacPkt and set all needed header fields. </p>

<p>Reimplemented from <a class="el" href="a00026.html#a0e1c8dad62e40f43a43c7b8a0cb71501">BaseMacLayer</a>.</p>
<div class="fragment"><pre class="fragment">                                                               {
    <a class="code" href="a00224.html">UWBIRMacPkt</a>* encaps = <span class="keyword">new</span> <a class="code" href="a00224.html">UWBIRMacPkt</a>(msg-&gt;getName(), msg-&gt;getKind());
    encaps-&gt;setByteLength(<a class="code" href="a00026.html#a26ddb186455b73c8dc8b5698296804d2" title="Pointer to the arp module.">headerLength</a>);

    <span class="comment">// copy dest address from the Control Info attached to the network</span>
    <span class="comment">// mesage by the network layer</span>
    cObject *<span class="keyword">const</span> cInfo = msg-&gt;removeControlInfo();

    debugEV &lt;&lt;<span class="stringliteral">&quot;CInfo removed, mac addr=&quot;</span>&lt;&lt; <a class="code" href="a00026.html#a48135ffa21044a71d92149d5301f9deb" title="Extracts the MAC address from the &quot;control info&quot; structure (object).">getUpperDestinationFromControlInfo</a>(cInfo) &lt;&lt; endl;
    encaps-&gt;setDestAddr(<a class="code" href="a00026.html#a48135ffa21044a71d92149d5301f9deb" title="Extracts the MAC address from the &quot;control info&quot; structure (object).">getUpperDestinationFromControlInfo</a>(cInfo));

    <span class="comment">//delete the control info</span>
    <span class="keyword">delete</span> cInfo;

    <span class="comment">//set the src address to own mac address</span>
    encaps-&gt;setSrcAddr(<a class="code" href="a00026.html#a8a26df9da07801d8ccb530530ef57ee2" title="MAC address.">myMacAddr</a>);

    <span class="comment">//encapsulate the network packet</span>
    encaps-&gt;encapsulate(msg);

    prepareData(encaps);

    nbSentPackets++;

  <span class="keywordflow">return</span> encaps;
}
</pre></div>
</div>
</div>
<a class="anchor" id="a585dd6a0b5c3c6a33e1f760ccd8ac29e"></a><!-- doxytag: member="AlohaMacLayer::handleLowerMsg" ref="a585dd6a0b5c3c6a33e1f760ccd8ac29e" args="(cMessage *msg)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void AlohaMacLayer::handleLowerMsg </td>
          <td>(</td>
          <td class="paramtype">cMessage *&#160;</td>
          <td class="paramname"><em>msg</em></td><td>)</td>
          <td><code> [protected, virtual]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>If message arrives from lower layer, check whether it is for us. Send it up if yes.</p>
<p>This basic implementation just forwards all message that are broadcast (destAddr = L2BROADCAST) or destined for this node (destAddr = nic module getId()) to the network layer</p>
<dl class="see"><dt><b>See also:</b></dt><dd><a class="el" href="a00025.html#adbf061566606041db811b519f0400ed5" title="Sends a message to the upper layer.">sendUp</a> </dd></dl>

<p>Reimplemented from <a class="el" href="a00223.html#acac82faa5c2357def7a7c0ac2363b88b">UWBIRMac</a>.</p>
<div class="fragment"><pre class="fragment">                                                {
    <a class="code" href="a00224.html">UWBIRMacPkt</a> *mac = <span class="keyword">static_cast&lt;</span><a class="code" href="a00224.html">UWBIRMacPkt</a> *<span class="keyword">&gt;</span>(msg);

    <span class="keywordflow">if</span>(validatePacket(mac)) {
        <span class="keyword">const</span> <a class="code" href="a00117.html#aea56b60dcb5ae8c2bde465271daf7210" title="Type definition for a L2 (MAC) address.">LAddress::L2Type</a>&amp; dest = mac-&gt;getDestAddr();
        <span class="keyword">const</span> <a class="code" href="a00117.html#aea56b60dcb5ae8c2bde465271daf7210" title="Type definition for a L2 (MAC) address.">LAddress::L2Type</a>&amp; src  = mac-&gt;getSrcAddr();
        <span class="keywordflow">if</span> ((dest == <a class="code" href="a00026.html#a8a26df9da07801d8ccb530530ef57ee2" title="MAC address.">myMacAddr</a>)) {
          debugEV &lt;&lt; <span class="stringliteral">&quot;message with mac addr &quot;</span> &lt;&lt; src
                    &lt;&lt; <span class="stringliteral">&quot; for me (dest=&quot;</span> &lt;&lt; dest
                    &lt;&lt; <span class="stringliteral">&quot;) -&gt; forward packet to upper layer&quot;</span> &lt;&lt; std::endl;
            <a class="code" href="a00025.html#adbf061566606041db811b519f0400ed5" title="Sends a message to the upper layer.">sendUp</a>(<a class="code" href="a00026.html#a998b4c4c56074a354b50f8c4fc5d6d4c" title="decapsulate the network message from the MacPkt">decapsMsg</a>(mac));
        } <span class="keywordflow">else</span> {
          debugEV &lt;&lt; <span class="stringliteral">&quot;message with mac addr &quot;</span> &lt;&lt; src
                    &lt;&lt; <span class="stringliteral">&quot; not for me (dest=&quot;</span> &lt;&lt; dest
                    &lt;&lt; <span class="stringliteral">&quot;) -&gt; delete (my MAC=&quot;</span> &lt;&lt; <a class="code" href="a00026.html#a8a26df9da07801d8ccb530530ef57ee2" title="MAC address.">myMacAddr</a> &lt;&lt; <span class="stringliteral">&quot;)&quot;</span> &lt;&lt; std::endl;
            <span class="keyword">delete</span> mac;
        }
    } <span class="keywordflow">else</span> {
      debugEV &lt;&lt; <span class="stringliteral">&quot;Errors in message ; dropping mac packet.&quot;</span> &lt;&lt; std::endl;
        <span class="keyword">delete</span> mac;
    }
}
</pre></div>
</div>
</div>
<a class="anchor" id="abab6939a0c82122391528d386df97c2c"></a><!-- doxytag: member="AlohaMacLayer::initialize" ref="abab6939a0c82122391528d386df97c2c" args="(int stage)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void AlohaMacLayer::initialize </td>
          <td>(</td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>stage</em></td><td>)</td>
          <td><code> [virtual]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Initialization of the module and some variables. </p>
<p>First we have to initialize the module from which we derived ours, in this case <a class="el" href="a00025.html" title="A very simple layer template.">BaseLayer</a>. </p>

<p>Reimplemented from <a class="el" href="a00223.html#a0fcaae9c3cefb73372b7290ff4d9092d">UWBIRMac</a>.</p>

<p>References <a class="el" href="a00223.html#a0fcaae9c3cefb73372b7290ff4d9092d">UWBIRMac::initialize()</a>, <a class="el" href="a00117.html#a6db1e8dbd0d23dec49ce7b59f5c15976">LAddress::L2NULL</a>, <a class="el" href="a00141.html#a5d69aacb1cf6a57827f07224219fccb7a2c1aea88fe8363141c138da817461953">MiximRadio::RX</a>, and <a class="el" href="a00141.html#a5d69aacb1cf6a57827f07224219fccb7a4f6c3dfae0f5fccb76b1d42f6ccc785d">MiximRadio::TX</a>.</p>
<div class="fragment"><pre class="fragment">                                        {
  <a class="code" href="a00008.html#abab6939a0c82122391528d386df97c2c" title="Initialization of the module and some variables.">UWBIRMac::initialize</a>(stage);
  <span class="keywordflow">if</span>(stage == 1 &amp;&amp; <a class="code" href="a00026.html#a8a26df9da07801d8ccb530530ef57ee2" title="MAC address.">myMacAddr</a> != <a class="code" href="a00117.html#a6db1e8dbd0d23dec49ce7b59f5c15976" title="NULL address for L2 addresses.">LAddress::L2NULL</a>) {
            <a class="code" href="a00223.html#a11441696168ae8b05f3d5bb899478656" title="Handler to the physical layer.">phy</a>-&gt;<a class="code" href="a00134.html#ad25abbad9aa16bdbf24bf1dd582b1c6f" title="Tells the BasePhyLayer to switch to the specified radio state.">setRadioState</a>(<a class="code" href="a00141.html#a5d69aacb1cf6a57827f07224219fccb7a4f6c3dfae0f5fccb76b1d42f6ccc785d" title="transmitting state">MiximRadio::TX</a>);
    } <span class="keywordflow">else</span> <span class="keywordflow">if</span>(stage == 1 &amp;&amp; <a class="code" href="a00026.html#a8a26df9da07801d8ccb530530ef57ee2" title="MAC address.">myMacAddr</a> == <a class="code" href="a00117.html#a6db1e8dbd0d23dec49ce7b59f5c15976" title="NULL address for L2 addresses.">LAddress::L2NULL</a>) {
            <a class="code" href="a00223.html#a11441696168ae8b05f3d5bb899478656" title="Handler to the physical layer.">phy</a>-&gt;<a class="code" href="a00134.html#ad25abbad9aa16bdbf24bf1dd582b1c6f" title="Tells the BasePhyLayer to switch to the specified radio state.">setRadioState</a>(<a class="code" href="a00141.html#a5d69aacb1cf6a57827f07224219fccb7a2c1aea88fe8363141c138da817461953" title="receiving state">MiximRadio::RX</a>);
    }
}
</pre></div>
</div>
</div>
<hr/>The documentation for this class was generated from the following files:<ul>
<li>D:/Projects/MiXiM/extsrc/mixim/src/modules/mac/<a class="el" href="a00422_source.html">AlohaMacLayer.h</a></li>
<li>D:/Projects/MiXiM/extsrc/mixim/src/modules/mac/AlohaMacLayer.cc</li>
</ul>
</div>
</div>
  <div id="nav-path" class="navpath">
    <ul>
      <li class="navelem"><a class="el" href="a00008.html">AlohaMacLayer</a>      </li>

    <li class="footer">Generated on Tue Mar 5 2013 21:26:31 for MiXiM by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.5.1 </li>
   </ul>
 </div>


</body>
</html>
